package com.biz.service.basic;

import com.biz.model.Hmodel.TSysLog;
import com.biz.model.Pmodel.PSysLog;
import com.biz.service.base.BaseServiceImpl;
import com.framework.dao.mdao.DaoSupport;
import com.framework.model.Operation;
import com.framework.model.Pager;
import com.framework.utils.Tools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import javax.annotation.Resource;

/**
 * Created by tomchen on 17/1/7.
 */
@Service("logService")
public class LogServiceImpl extends BaseServiceImpl<TSysLog> implements LogServiceI {

    @Resource(name = "daoSupport")
    private DaoSupport dao;

    @Override
    public Pager<PSysLog> queryLogs(Pager pager) throws Exception {
        return dao.findForPager1("logDao.queryLogs", "logDao.queryLogsCount", pager);
    }


    /**
     * @param ip
     * @param userId
     * @param type
     * @param txt
     * @throws Exception
     */
    @Override
    public void saveLog(String ip, String userId, String type, String txt) {
        try {
            TSysLog tSysLog = new TSysLog();
            tSysLog.setUserName(userId);
            tSysLog.setType(type);
            tSysLog.setDetail(txt);
            tSysLog.setCreateTime(new Date());
            tSysLog.setIp(ip);
            this.save(tSysLog);
        }catch (Exception e){

        }
    }
}
